package com.ptu.mapper;

import com.ptu.entity.OrderItem;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OrderItemMapper {
    @Insert("insert into order_item (order_id, product_id, product_name, product_image, price, quantity, subtotal)" +
            " values (#{orderId}, #{productId}, #{productName}, #{productImage}, #{price}, #{quantity}, #{subtotal})"
    )
    void insert(OrderItem orderItem);

    // 新增订单项查询
    @Select("SELECT * FROM order_item WHERE order_id = #{orderId}")
    List<OrderItem> listItemsByOrderId(Long orderId);
}
